<?php

namespace apiend\controllers;

use Yii;
use apiend\components\Controller;
use apiend\models\forms\SmsCaptchaForm;

/**
 * 短信接口
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class SmsController extends Controller {

    public $checkUnitId = false;

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
            ],
        ];
    }

    /**
     * 普通类验证码
     * @return mixed
     */
    public function actionCaptcha() {
        $model = new SmsCaptchaForm();
        if (!$model->load(Yii::$app->request->post())) {
            $model->loadError('请设置发送所需的手机号和应用范围的信息');
        }
        return $model->send();
    }

}
